import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace OrderPackagePersonalizationApi {
  /** SPA订单套餐个性化选项信息 */
  export interface OrderPackagePersonalization {
    id: number; // 主键ID
    orderPackageId?: number; // 关联spa_order_package表ID
    personalizationId?: number; // 关联spa_package_personalization表ID
    optionKey?: string; // 选项键
    optionValue?: string; // 选项值
    optionLabel?: string; // 选项标签
    optionPrice: number; // 选项价格
    isSelected: boolean; // 是否已选择
    selectionTime: string | Dayjs; // 选择时间
    scope: string; // 权限范围
    scoperef: string; // 权限引用
  }
}

/** 查询SPA订单套餐个性化选项分页 */
export function getOrderPackagePersonalizationPage(params: PageParam) {
  return requestClient.get<PageResult<OrderPackagePersonalizationApi.OrderPackagePersonalization>>('/spa/order-package-personalization/page', { params });
}

/** 查询SPA订单套餐个性化选项详情 */
export function getOrderPackagePersonalization(id: number) {
  return requestClient.get<OrderPackagePersonalizationApi.OrderPackagePersonalization>(`/spa/order-package-personalization/get?id=${id}`);
}

/** 新增SPA订单套餐个性化选项 */
export function createOrderPackagePersonalization(data: OrderPackagePersonalizationApi.OrderPackagePersonalization) {
  return requestClient.post('/spa/order-package-personalization/create', data);
}

/** 修改SPA订单套餐个性化选项 */
export function updateOrderPackagePersonalization(data: OrderPackagePersonalizationApi.OrderPackagePersonalization) {
  return requestClient.put('/spa/order-package-personalization/update', data);
}

/** 删除SPA订单套餐个性化选项 */
export function deleteOrderPackagePersonalization(id: number) {
  return requestClient.delete(`/spa/order-package-personalization/delete?id=${id}`);
}


/** 导出SPA订单套餐个性化选项 */
export function exportOrderPackagePersonalization(params: any) {
  return requestClient.download('/spa/order-package-personalization/export-excel', { params });
}

